package com.roncoo.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.roncoo.order.entity.UserCourse;
import com.roncoo.order.dao.UserCourseMapper;
import com.roncoo.order.service.IUserCourseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jl
 * @since 2021-04-10
 */
@Service
public class UserCourseServiceImpl extends ServiceImpl<UserCourseMapper, UserCourse> implements IUserCourseService {


    /**
     * 查询用户是否购买课程
     * @param id
     * @param cid
     * @return
     */
    @Override
    public boolean getOneUser(Integer id, Integer cid) {
        QueryWrapper<UserCourse> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("course_id",cid);
        queryWrapper.eq("user_id",id);
        UserCourse one = this.getOne(queryWrapper);
        if (one!=null){
            return true;
        }else {
            return false;
        }
    }
}
